// import 'dart:io';
// import 'package:flutter/services.dart';
// import 'package:flutter_logger_server/flutter_logger_server_platform_interface.dart';
// import 'package:flutter_logger_server/utils/file_utils.dart';
// import 'package:shelf/shelf.dart' as shelf;
// import 'package:shelf/shelf_io.dart' as io;
// import 'package:shelf_static/shelf_static.dart';
//
// class FlutterLoggerServer {
//   final String assetsBasePath = 'packages/flutter_logger_server/lib/webserver/';
//   HttpServer? _server;
//
//
//   Future<String?> getPlatformVersion() {
//     return FlutterLoggerServerPlatform.instance.getPlatformVersion();
//   }
//
//   Future<void> startServer() async {
//     //返回assets/webserver/的目录打印出来
//     final rootHtmlPath = await FileUtils.copyHtmlToLocal();
//
//     print('rootHtmlPath: $rootHtmlPath');
//
//     var pipeline = const shelf.Pipeline();
//
//     pipeline = pipeline.addMiddleware(shelf.logRequests());
//     String? defaultDoc = 'index.html';
//     // ByteData data = await rootBundle.load(join(assetsBasePath, path));
//     final handler = pipeline.addHandler(createStaticHandler(rootHtmlPath,
//         defaultDocument: defaultDoc, listDirectories: true));
//     _server = await io.serve(handler, 'localhost', 9999);
//     print('Serving at http://${_server?.address.host}:${_server?.port}');
//     _server!.autoCompress = true;
//   }
//
//   void stopServer() {
//     _server?.close();
//   }
// }
//
